package com.orange.base.component.biztool.simulateddata.service.impl;

import com.orange.base.component.biztool.simulateddata.service.SimulatedDataEnum;
import com.orange.base.component.biztool.simulateddata.service.SimulatedDataParam;

/**
 * 邮箱
 *
 * @author biankudingcha
 * @date: 2022-08-24
 * @since 0.5.0
 */
public class EmailStrategy extends AbstractSimulatedData {

    public String getType() {
        return SimulatedDataEnum.EMAIL.getName();
    }

    public String getCaption() {
        return SimulatedDataEnum.EMAIL.getCaption();
    }

    private static final String[] EMAIL_SUFFIX = "@gmail.com,@yahoo.com,@msn.com,@hotmail.com,@aol.com,@ask.com,@live.com,@qq.com,@0355.net,@163.com,@163.net,@263.net,@3721.net,@yeah.net,@googlemail.com,@126.com,@sina.com,@sohu.com,@yahoo.com.cn"
        .split(",");

    @Override
    public Object getValue(SimulatedDataParam param) {
        return generate(param);
    }

    private static String generate(SimulatedDataParam param) {
        int length = getRandomNumber(6, 20);
        String name = randomString(length);
        String email = name + EMAIL_SUFFIX[getRandomNumber(0, EMAIL_SUFFIX.length - 1)];
        return email;
    }

}
